package system.common;

import system.util.DateUtil;
import system.util.StringUtil;

public class Arguments {
	private String Parameter0;		// Command
	private String Parameter1;		// (Conditional) Duration Type
	private String Parameter2;		// (Conditional) Start from Time
	private String Parameter3;		// (Conditional) End to Time
	private int DurationValue;			// Duration Value
	private String DBName;			// DB Name - Date
	private String DBFullName;		// DB Full Name
	private String TableName1;		// Table Full Name 1
	private String TableName2;		// Table Full Name 2
	private String FileName1;			// File Name 1
	private String FileName2;			// File Name 2
	
	public String getParameter0() {
		return Parameter0;
	}
	public void setParameter0(String Parameter0) {
		this.Parameter0 = Parameter0;
	}
	public String getParameter1() {
		return Parameter1;
	}
	public void setParameter1(String Parameter1) {
		this.Parameter1 = Parameter1;
	}
	public String getParameter2() {
		return Parameter2;
	}
	public void setParameter2(String Parameter2) {
		this.setFileName1(DateUtil.getFmtDateTime(Parameter2, "", 22));
		this.setDBName(DateUtil.getFmtDateTime(Parameter2, "", 8));
		this.Parameter2 = this.convertParameter(Parameter2);
	}
//	public void setParameter2(String Parameter2) {
//		String str = "";
//		if (this.Parameter1.equals("DAY")) {
//			str = parameter2 + "0000";
//		} else if (this.Parameter1.equals("HOUR")) {
//			str = parameter2 + "00";
//		} else {
//			str = parameter2;
//		}
//		this.setFileName1(str);
//		this.setDBName(str.substring(0, 8));
//		this.Parameter2 = this.convertParameter(str);
//	}
	public void setParameter2(String Parameter2, int cmd) {
		switch (cmd) {
		case 1: // yyyy-MM-dd HH:mm
			this.Parameter2 = DateUtil.getFmtDateTime(Parameter2, 12);
			break;
		default: // default
			this.Parameter2 = Parameter2;
			break;
		}
	}
	public String getParameter3() {
		return Parameter3;
	}
	public void setParameter3(String Parameter3) {
		String str = "";
		if (this.Parameter1.equals("DAY")) {
			str = Parameter3.substring(0, 8) + "2359";
		} else if (this.Parameter1.equals("HOUR")) {
			str = Parameter3.substring(0, 10) + "59";
		} else if (this.Parameter1.equals("MIN")) {
			str = Parameter3.substring(0, 12);
		}
		this.setFileName2(DateUtil.getFmtDateTime(Parameter3, "", 22));
		this.Parameter3 = this.convertParameter(str);
	}
//	public void setParameter3(String parameter3) {
//		String str = "";
//		if (this.Parameter1.equals("DAY")) {
//			str = parameter3 + "2359";
//		} else if (this.Parameter1.equals("HOUR")) {
//			str = parameter3 + "59";
//		} else {
//			str = parameter3;
//		}
//		this.setFileName2(str);
//		this.Parameter3 = this.convertParameter(str);
//	}
	/**
	 * set a parameter3
	 * @param parameter3
	 * @param cmds
	 */
	public void setParameter3(String Parameter3, int cmd) {
		switch (cmd) {
		case 1: // yyyy-MM-dd HH:mm
			this.Parameter3 = DateUtil.getFmtDateTime(Parameter3, 12);
			break;
		default: // default
			this.Parameter3 = Parameter3;
			break;
		}
	}
	/**
	 * @return the durationValue
	 */
	public int getDurationValue() {
		return DurationValue;
	}
	/**
	 * @param durationValue the durationValue to set
	 */
	public void setDurationValue(int DurationValue) {
		this.DurationValue = DurationValue;
	}
	public String getDBName() {
		return DBName;
	}
	public void setDBName(String DBName) {
		if (this.Parameter0.equals("WEBKEEPER_01")) {
			this.DBName = StringUtil.replaceAll(DateUtil.getFmtDateTime(DBName), "-", "_");
		} else {
			this.DBName = DBName;
		}
	}
	public String getDBFullName() {
		return DBFullName;
	}
	public void setDBFullName(String DBFullName) {
		this.DBFullName = DBFullName;
	}
	public String getTableName1() {
		return TableName1;
	}
	public void setTableName1(String TableName1) {
		this.TableName1 = TableName1;
	}
	public String getTableName2() {
		return TableName2;
	}
	public void setTableName2(String TableName2) {
		this.TableName2 = TableName2;
	}
	public String getFileName1() {
		return FileName1;
	}
	public void setFileName1(String FileName1) {
		this.FileName1 = FileName1;
	}
	public String getFileName2() {
		return FileName2;
	}
	public void setFileName2(String FileName2) {
		this.FileName2 = FileName2;
	}
	
	private String convertParameter(String str) {
		if (this.Parameter0.equals("WEBKEEPER_01") || this.Parameter0.equals("WEBKEEPER_02")
				|| this.Parameter0.equals("WEBKEEPER_MIGRATE_01") || this.Parameter0.equals("WEBKEEPER_MIGRATE_02")
				|| this.Parameter0.equals("MSG_I_01") || this.Parameter0.equals("MSG_I_02")
				|| this.Parameter0.equals("MSG_I_03") || this.Parameter0.equals("DB_I_01")
				|| this.Parameter0.equals("PRIVACY_I_01") || this.Parameter0.equals("REDCASTLE_01")
				|| this.Parameter0.equals("REDCASTLE_02") || this.Parameter0.equals("REDCASTLE_03")
				|| this.Parameter0.equals("IDESK_01")) {
			str = DateUtil.getFmtDateTime(str, 12);
		} else {
			str = DateUtil.getFmtDateTime(str, "", 22);
		}
		return str;
	}
}